package com.example.demo.controller;

import com.example.demo.domain.BudgetActual;
import com.example.demo.domain.BudgetType;
import com.example.demo.service.BudgetActualService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
public class BudgetActualController {

    @Resource
    private BudgetActualService budgetActualService;

    @GetMapping("/getAllCost")
    @ResponseBody
    public Map<String, Object> getAllCost(String type){
        return budgetActualService.getAllCost(type);
    }

    @GetMapping("/getCostSum")
    @ResponseBody
    public Map<String, Object> getCostSum(String type) {
        return budgetActualService.getCostSum(type);
    }

    @GetMapping("/getActualMonth")
    @ResponseBody
    public BudgetActual getActualMonth(int id) {
        return budgetActualService.getActualMonth(id);
    }

    @GetMapping("/getResult")
    @ResponseBody
    public List<BudgetActual> getResult(String type){
        return budgetActualService.getResult(type);
    }

    @GetMapping("/getDataList")
    @ResponseBody
    public List<BudgetActual> getDataList(String type) {
        return budgetActualService.getDataList(type);
    }

    @PostMapping("/save")
    @ResponseBody
    public int save(@RequestBody List<BudgetActual> budgetActual) {
        return budgetActualService.save(budgetActual);
    }

    @PostMapping("/saveActual")
    @ResponseBody
    public int saveActual(@RequestBody List<BudgetActual> budgetActual) {
        return budgetActualService.saveActual(budgetActual);
    }

    @GetMapping("/getTarget")
    @ResponseBody
    public Map<String, Object> getTarget(String type){
        return budgetActualService.getTarget(type);
    }

    @GetMapping("/delTarget")
    @ResponseBody
    public int delTarget(int id){
        return budgetActualService.delTarget(id);
    }

}
